#include <cstdio>                                                                                                      
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <queue>
#include "wn.h"
#include <map>
#define NOUN 1

using namespace std;
static string do_is_defined(char *searchword)
{
    int i, found = 0;
    unsigned int search;
    char *morphword;

    /* Print all valid searches for word in all parts of speech */

    strtolower(strsubst(searchword, ' ', '_'));
	    
    i = NOUN; //noun
    if ((search = is_defined(searchword, i)) != 0) 
    {
        return searchword;
    } 
    return "";
}
int main()
{
    ifstream purposes;
    purposes.open("purpose.suffix.dedup");
    if (wninit()) {		// open database 
	    cerr <<"wn: Fatal error - cannot open WordNet database" << endl;
	    exit (-1);
    }
    int count = 0;
    string temp;
    while (getline(purposes, temp))
    {
        string name;
        if (temp.rfind(' ') != -1)
        {
            name = temp.substr(temp.rfind(' ') + 1);
        }
        else
        {
            name = temp;
        }
        if (string(do_is_defined(const_cast<char*>(name.c_str()))).empty())
        {
            cout << temp << endl;
            count++;
        }
    }
    cout << "miss hit number = " << count << endl;
    purposes.close();
}
